import axios from "axios"

//封装axios
const requests = axios.create({
    baseURL:'https://39.107.71.254:8443',
    timeout:5000
})


//请求拦截器
requests.interceptors.request.use((config)=>{
    const token = window.sessionStorage.getItem('token')
    if(token){
        config.headers.token = token
    }
    return config
})

//响应拦截器
requests.interceptors.response.use((res)=>{
   return res.data
}),(error)=>{
    //响应失败回调
    return Promise.reject(new Error(error))
}

export default  requests